let user=null;

layui.use('form',function (){
    let $=layui.jquery;
    initUser=function () {
        $.ajax({
            url: '/user/getMySelf',
            type: 'GET',
            dataType: "json",
            success: function (res) {
                if(res.result){

                    user=res.data
                    document.getElementById("name").innerHTML = res.data.name;
                    document.getElementById("agv").setAttribute("style","");
                    document.getElementById("login").setAttribute("style","display:none")
                    document.getElementById("center").setAttribute("style","")
                    document.getElementById("logout").setAttribute("style","")
                }

            }
        })
    }

    pickTask=function (id,status,type,pickName,phone){
        $.ajax({
            url: '/task/pick',
            data: JSON.stringify({
                "pickId":user.id,
                "id":id,
                "pickName":pickName,
                "status":status,
                "type":type,
                "pickPhone":phone
            }),
            contentType:'application/json;charset=utf-8',
            type: 'POST', //HTTP请求类型
            dataType:"json",
            success: function (res) {
                if(res.code===200){
                    layer.msg(res.msg, {icon: 1});
                    if(type=="VOLUNTEER"){
                        searchVolunteer();
                    }else{
                        searchOther();
                    }
                    // searchTask($('#myName').val(),type)
                }else{
                    layer.msg(res.msg, {icon: 5});
                }
            }, error: function (res) {
                layer.msg(res.msg, {icon: 5});
            }

        })
    }
    idLogin=function (){

        if(user!=null & user!=undefined){
            return true;
        }else
        {
            return  false;
        }
    }
})
